import React from 'react';
import { Tooltip } from 'antd';
import { AUDIT } from '../../utils/constant';
import { COLOR } from 'src/utils/color';

export default function AuditStatus({ record, text }) {
  let color = 'orange';
  switch (record.audit_status) {
    case AUDIT._WAIT:
      color = COLOR._ORANGE;
      break;
    case AUDIT._RESOLUE:
      color = COLOR._COLOR_02;
      break;
    case AUDIT._REJECT:
      color = COLOR._RED;
      break;
    default:
      color = COLOR._ORANGE;
      break;
  }
  return (
    <>
      {record.audit_detail && (
        <Tooltip
          title={
            <>
              {record.audit_status === AUDIT._WAIT && (
                <>
                  <div>提交时间:{record.audit_detail.submit_time}</div>
                  <div>提交人:{record.audit_detail.submit_user_name}</div>
                </>
              )}
              {(record.audit_status === AUDIT._RESOLUE || record.audit_status === AUDIT._REJECT) && (
                <>
                  <div>提交时间:{record.audit_detail.submit_time}</div>
                  <div>提交人:{record.audit_detail.submit_user_name}</div>
                  <div>审核时间:{record.audit_detail.audit_time}</div>
                  <div>审核人:{record.audit_detail.audit_user_name}</div>
                </>
              )}
            </>
          }
        >
          <span style={{ color: color }}>{text}</span>
        </Tooltip>
      )}
    </>
  );
}
